const express = require('express');
const router = express.Router();
const CategoryController = require('../controllers/categoryController');
const authMiddleware = require('../middlewares/authMiddleware');
const upload = require('../middlewares/uploadMiddleware');

// 获取所有分类
router.get('/', CategoryController.getAllCategories);

// 获取分类详情
router.get('/:id', CategoryController.getCategoryById);

// 创建分类 (需要管理员权限)
router.post('/', authMiddleware, upload.single('image'), CategoryController.createCategory);

// 更新分类 (需要管理员权限)
router.put('/:id', authMiddleware, upload.single('image'), CategoryController.updateCategory);

// 删除分类 (需要管理员权限)
router.delete('/:id', authMiddleware, CategoryController.deleteCategory);

module.exports = router;